package com.java80.springmall.cloud.product.provider.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.java80.springmall.cloud.product.provider.entity.Product;
import com.java80.springmall.cloud.product.provider.repository.ProductRepository;
import com.java80.springmall.cloud.product.provider.service.ProductService;

@RestController
@RequestMapping("/product/")
public class ProductController {
	@Autowired
	private ProductService svc;
	@GetMapping("findAll")
	public List<Product> findAll(){
		return svc.findAll();
	}
	@GetMapping("get")
	public Product get(long id){
		return svc.get(id);
	}
	@PostMapping("updateStored")
	public boolean updateStored(long productId,int nums){
		int updateStored = svc.updateStored(productId, nums);
		return updateStored==1;
	}
}
